require 'java'
require 'rubygems'
gem 'glimmer'
import 'org.eclipse.swt.SWT'

class MyView < Java::org.eclipse.ui.part.ViewPart
  include_package 'org.eclipse.swt'
  include_package 'org.eclipse.swt.layout'
  require 'glimmer'
  require 'command_handlers'
    
  include Glimmer
    
	def createPartControl(parent) 
		
		l = GridLayout.new
    l.numColumns = 4
    
    @contents = composite {
      text "SWT"
      composite {
        label { 
          text "Hello World!" 
        }
      }
    }
    container = RWidget.new("composite", parent, SWT::NONE)
    Glimmer.add_contents(container) do
      text "SWT"
      composite {
        label { 
          text "Hello World!" 
        }
      }
	  end    
		
	end

	def setFocus()
    	
	end
	
    def dispose()
    	
    end
    
  # the "part" class must implement a meaningful equals() method
  # as the PartTester class will verify this 
  def equals(object)
    if object.nil?
      return false
    end
    
    if object.equal?(self)
      return true
    elsif object.kind_of?(Java::org.eclipse.ui.IViewPart)
      return true
    end
    
    return false
  end  
end

class MyListener  
  include org.eclipse.swt.widgets.Listener

  attr_accessor :l
  attr_accessor :t
	
    def initialize(label, text)
        @l = label
        @t = text      
    end
    def handleEvent(event) 
        l.setText(t.getText())
    end
end

$view = MyView.new()
$view

